/**
* Created by wust on 2020-11-20 22:27:21.
*/
<template>
  <el-form ref="formModel" :model="formModel" :rules="rules" label-width="120px" style="width:70%;" @submit.native.prevent>
    <el-form-item label="code" prop="code">
<el-input v-model="formModel.code"></el-input>
</el-form-item>
<el-form-item label="name_full_name" prop="nameFullName">
<el-input v-model="formModel.nameFullName"></el-input>
</el-form-item>
<el-form-item label="short_name" prop="shortName">
<el-input v-model="formModel.shortName"></el-input>
</el-form-item>
<el-form-item label="contact_person" prop="contactPerson">
<el-input v-model="formModel.contactPerson"></el-input>
</el-form-item>
<el-form-item label="contact_person_mobile_phone" prop="contactPersonMobilePhone">
<el-input v-model="formModel.contactPersonMobilePhone"></el-input>
</el-form-item>
<el-form-item label="registered_address" prop="registeredAddress">
<el-input v-model="formModel.registeredAddress"></el-input>
</el-form-item>
<el-form-item label="current_address" prop="currentAddress">
<el-input v-model="formModel.currentAddress"></el-input>
</el-form-item>
<el-form-item label="fixed_line_telephone" prop="fixedLineTelephone">
<el-input v-model="formModel.fixedLineTelephone"></el-input>
</el-form-item>
<el-form-item label="email" prop="email">
<el-input v-model="formModel.email"></el-input>
</el-form-item>
<el-form-item label="state" prop="state">
<el-input v-model="formModel.state"></el-input>
</el-form-item>
<el-form-item label="description" prop="description">
<el-input v-model="formModel.description"></el-input>
</el-form-item>
<el-form-item label="is_deleted" prop="isDeleted">
<el-input v-model="formModel.isDeleted"></el-input>
</el-form-item>

    <el-form-item style="text-align: left;">
      <el-button type="primary" @click="onSubmit('formModel')" :loading="submitting">提交</el-button>
    </el-form-item>
  </el-form>
</template>
<script>
import Vue from 'vue'

export default {
  name: 'tenant-create',
  data () {
    return {
      submitting: false,
      formModel: {
        code: null,
nameFullName: null,
shortName: null,
contactPerson: null,
contactPersonMobilePhone: null,
registeredAddress: null,
currentAddress: null,
fixedLineTelephone: null,
email: null,
state: null,
description: null,
isDeleted: null,

      },
      rules: {
      }
    }
  },
  methods: {
    onSubmit: function (formData) {
      this.$refs[formData].validate((valid) => {
        if (!valid) {
        } else {
          this.submitting = true
          Vue.$ajax({
            method: 'post',
            url: Vue.$adminServerURL + '/web/v1/TenantController',
            data: this.formModel
          }).then(res => {
            this.submitting = false
            if (res.data.flag !== 'SUCCESS') {
              if (!Vue.$isNullOrIsBlankOrIsUndefined(res.data.message)) {
                this.$message({
                  message: res.data.message,
                  type: 'warning'
                })
              }
            } else {
              this.$message({
                message: res.data.message,
                type: 'success'
              })
              this.resetForm('formModel')
            }
          })
        }
      })
    },
    resetForm (formData) {
      this.$refs[formData].resetFields()
    }
  }
}
</script>
